package com.jackstraw.create.param;

import java.util.HashMap;
import java.util.Map;

/**
 * 创建者：文和
 * 创建时间: 2019-11-05
 * 描述：
 * 其它：
 **/
public class ImportPackageMap {

    /**
     * 变量类型对应的引包map
     */
    private static Map<String, String> map = new HashMap<>();

    static {
        map.put("date", "java.util.Date;" + System.lineSeparator() +
                "import com.fasterxml.jackson.annotation.JsonFormat;" + System.lineSeparator() +
                "import org.springframework.format.annotation.DateTimeFormat;");
//        map.put("datetime", "java.util.Date" + System.lineSeparator() +
//                "import com.fasterxml.jackson.annotation.JsonFormat;" + System.lineSeparator() +
//                "import org.springframework.format.annotation.DateTimeFormat;");
        map.put("datetime", "java.time.LocalDateTime" + System.lineSeparator() +
                "import com.fasterxml.jackson.annotation.JsonFormat;" + System.lineSeparator() +
                "import org.springframework.format.annotation.DateTimeFormat;");
        map.put("tableid", "com.baomidou.mybatisplus.annotation.TableField");
        map.put("map", "java.util.Map");
        map.put("hashmap", "java.util.HashMap");
        map.put("set", "java.util.Set");
        map.put("list", "java.util.List");
        map.put("bigdecimal", "java.math.BigDecimal");
        map.put("data", "lombok.Data");
        map.put("mapper", "org.apache.ibatis.annotations.Mapper");
        map.put("requestbody", "org.springframework.web.bind.annotation.RequestBody");
        map.put("autowired", "org.springframework.beans.factory.annotation.Autowired");
        map.put("resource", "javax.annotation.Resource");
        map.put("service", "org.springframework.transaction.annotation.Transactional");
        map.put("transactional", "org.springframework.stereotype.Service");
        map.put("controller", "org.springframework.stereotype.Controller");
        map.put("requestmapping", "org.springframework.web.bind.annotation.RequestMapping");
        map.put("requestparam", "org.springframework.web.bind.annotation.RequestParam");
        map.put("getmapping", "org.springframework.web.bind.annotation.GetMapping");
        map.put("postmapping", "org.springframework.web.bind.annotation.PostMapping");
        map.put("restcontroller", "org.springframework.web.bind.annotation.RestController");
        map.put("responsebody", "org.springframework.web.bind.annotation.ResponseBody");
        map.put("slf4j", "lombok.extern.slf4j.Slf4j");
        map.put("pagehelper", "com.github.pagehelper.PageHelper");
        map.put("pageinfo", "com.github.pagehelper.PageInfo");
        map.put("typereference", "com.fasterxml.jackson.core.type.TypeReference");
        map.put("param", "org.apache.ibatis.annotations.Param");
        map.put("localdatetime", "java.time.LocalDateTime;\n" +
                "import com.fasterxml.jackson.annotation.JsonFormat;\n" +
                "import org.springframework.format.annotation.DateTimeFormat");
        map.put("localdate", "java.time.LocalDate;\n" +
                "import com.fasterxml.jackson.annotation.JsonFormat;\n" +
                "import org.springframework.format.annotation.DateTimeFormat");
    }

    /**
     * 根据数据类型获取常用的引包
     *
     * @param fieldType
     * @return
     */
    public static String getImportLineByFieldType(String fieldType) {
        fieldType = fieldType.toLowerCase();
        String packagePath = map.get(fieldType);
        return packagePath;
    }
}
